<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class FangRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    //验证规则
    public function rules()
    {
        return [
            'fang_name'     =>  'required',
            'fang_xiaoqu'   =>  'required',
            'fang_addr'      =>  'required',
            'fang_desn'      =>  'required',
            'fang_province' =>  'numeric|min:1',
            'fang_ting'     =>  'numeric|min:1',
            'fang_region'   =>  'numeric|min:1',
            'fang_rent'     =>  'required',
            'fang_floor'    =>  'required',
            'fang_year'     =>  'min:4|max:4',
        ];
    }
    //验证提示
    public function messages(){
        return [
            'fang_name.required'    =>  '房源名称不能为空',
            'fang_xiaoqu.required'  =>  '小区名称不能为空',
            'fang_addr.required'     =>  '房源地址不能为空',
            'fang_desn.required'    =>  '描述不能为空',
            'fang_province.min'     =>  '请选择省份',
            'fang_ting.min'         =>  '请选择市份',
            'fang_region.min'       =>  '请选择区/县',
            'fang_rent.required'    =>  '租金不能为空',
            'fang_floor.required'   =>  '楼层不能为空',
            'fang_year.min'         =>  '请选择正确的年份',
            'fang_year.max'         =>  '请选择正确的年份',

        ];
    }
}
